<?php

class Welcome extends Controller {

	function Welcome()
	{
		parent::Controller();
		//$this->load->scaffolding('items');
		$this->load->helper('admin');
	}
	
	function index()
	{
		//get the theme
		$theme = $this->Settings_Model->get_theme();
		
		//get the pages for the sidebar
		$data['pages'] = $this->Pages_Model->get_all_pages();
		$data['categories'] = $this->Categories_Model->get_hierarchy();
		
		$page = $this->Pages_Model->get_page_from_slug('homepage');
		$data['location'] = 'homepage';
		
		$data['title'] = $page->title;
		$data['content'] = $page->content;
		
		$this->load->view('themes/' . $theme . '/index', $data);
	}
	
	function page() {
		//get the theme
		$theme = $this->Settings_Model->get_theme();
		
		//get the pages for the sidebar
		$data['pages'] = $this->Pages_Model->get_all_pages();
		$data['categories'] = $this->Categories_Model->get_hierarchy();
		$page = $this->Pages_Model->get_page_from_slug($this->uri->segment(3));
		$data['location'] = $this->uri->segment(3);
		
		$data['title'] = $page->title;
		$data['content'] = $page->content;
		
		$this->load->view('themes/' . $theme . '/index', $data);
	}
	
	function apage() {
		//ajax loading
		$page = $this->Pages_Model->get_page_from_slug($this->uri->segment(3));
		
		echo '<h2>' . $page->title . '</h2>';
		echo $page->content;
	}
	
	
}
?>